import request from '@/utils/request'

export const authApi = {
  // 登录
  login: (data) => {
    const formData = new FormData()
    formData.append('username', data.username)
    formData.append('password', data.password)
    
    return request({
      url: '/api/v1/auth/login',
      method: 'post',
      data: formData,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  },

  // 注册
  register: (data) => {
    return request({
      url: '/api/v1/auth/register',
      method: 'post',
      data
    })
  },

  // 登出
  logout: () => {
    return request({
      url: '/api/v1/auth/logout',
      method: 'post'
    })
  },

  // 获取当前用户信息
  getCurrentUser: () => {
    return request({
      url: '/api/v1/auth/me',
      method: 'get'
    })
  }
} 